package com.test.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Random;
import java.util.UUID;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/12/1 9:46
 */
@Repository
public class UserDao {

    @Autowired
    private JdbcTemplate template;

    public void instert() {
        String sql = "INSERT INTO tbl_user(username, age) VALUES (?,?)";
        String name = UUID.randomUUID().toString().substring(0, 5);
        int age = new Random().nextInt(100) + 1;
        template.update(sql, name, age);
    }
}
